package chooongg.base.widget.hText

import android.content.Context
import android.graphics.Canvas
import android.text.TextUtils
import android.util.AttributeSet

class ScaleTextView @JvmOverloads constructor(
    context: Context?,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : HTextView(context!!, attrs, defStyleAttr) {

    private val scaleText: ScaleText = ScaleText()

    override fun setAnimationListener(listener: AnimationListener?) {
        scaleText.setAnimationListener(listener)
    }

    override fun onDraw(canvas: Canvas) {
        scaleText.onDraw(canvas)
    }

    override fun setProgress(progress: Float) {
        scaleText.progress = progress
    }

    override fun animateText(text: CharSequence?) {
        scaleText.animateText(text)
    }

    init {
        scaleText.init(this, attrs, defStyleAttr)
        maxLines = 1
        ellipsize = TextUtils.TruncateAt.END
    }
}